package com.hermit.qmst.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hermit.qmst.R;
import com.hermit.qmst.mode.BusinessInfo;
import com.hermit.qmst.tools.Log;
import com.hermit.qmst.tools.Utils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/1/5 0005.
 */
public class SystemMessageAdapter extends BaseAdapter {
    private Context context;
    public List<BusinessInfo> data;

    public SystemMessageAdapter(Context context) {
        this.context = context;
        data = new ArrayList<BusinessInfo>();
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_sysytem_messge, null);

            holder.mTvCon = (TextView) convertView.findViewById(R.id.tv_con);
            holder.mTvTitle = (TextView) convertView.findViewById(R.id.tv_title);
            holder.mTvTime = (TextView) convertView.findViewById(R.id.tv_time);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.mTvTitle.setText(data.get(position).getTitle());
//        data.get(position).getImg()
        holder.mTvTime.setText(Utils.stampToDate(data.get(position).getImg()));
        Log.i("SystemMessageAdapter", data.get(position).getAddress()+"==", true);
        holder.mTvCon.setText(data.get(position).getAddress());
        return convertView;
    }


    static class ViewHolder {
        TextView mTvTitle;
        TextView mTvTime;
        TextView mTvCon;
    }
}
